package slim3.demo.controller.six;


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.URL;
import java.net.URLConnection;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.TimeZone;



public class UNIAirTime {
	
    public static void main(String[] args) throws Exception {

//        UNIAirTime test = new UNIAirTime();
//        ArrayList<FlightBean> beans = test.getKNH();
        
//        for (int i=0; i<beans.size(); i++) {
//            System.out.println(beans.get(i).toString());
//        }
        
        
//        String temp = "<td class=\"content\" align=\"center\" bgcolor=\"#B0DDFA\">B70887</td><td class=\"content\" align=\"center\" bgcolor=\"#B0DDFA\">1</td><td class=\"content\" align=\"center\" bgcolor=\"#B0DDFA\"><a href='#1' class=contentlink onclick=query('TSA','C','','');>TSA</a></td><td class=\"content\" align=\"center\" bgcolor=\"#B0DDFA\"><a href='#1' class=contentlink onclick=query('KNH','C','','');>KNH</a></td><td class=\"content\" align=\"center\" bgcolor=\"#B0DDFA\">12/08/21 11:15</td><td class=\"content\" align=\"center\" bgcolor=\"#B0DDFA\">12/08/21 12:10</td><td class=\"content\" align=\"center\" bgcolor=\"#B0DDFA\">12/08/21 11:15</td><td class=\"content\" align=\"center\" bgcolor=\"#B0DDFA\">12/08/21 12:32</td><td class=\"content\" align=\"center\" bgcolor=\"#B0DDFA\"><font color=\"Red\">12/08/21 11:25</font></td><td class=\"content\" align=\"center\" bgcolor=\"#B0DDFA\"><font color=\"Red\">12/08/21 12:31</font></td><td class=\"txtg\" align=\"center\" bgcolor=\"#B0DDFA\">抵達</td><td class=\"content\" align=\"center\" bgcolor=\"#B0DDFA\">-</td>";
//        System.out.println(temp.contains("B70887"));
//        System.out.println(temp.contains("B70889"));
//		
//		temp = "</tr><tr class=\"row1\">";
//		System.out.println(temp.contains("B70887"));
//        System.out.println(temp.contains("B70889"));
//        
//		temp = "<td class=\"content\" align=\"center\" bgcolor=\"#D1EEDC\">B70889</td><td class=\"content\" align=\"center\" bgcolor=\"#D1EEDC\">1</td><td class=\"content\" align=\"center\" bgcolor=\"#D1EEDC\"><a href='#1' class=contentlink onclick=query('TSA','C','','');>TSA</a></td><td class=\"content\" align=\"center\" bgcolor=\"#D1EEDC\"><a href='#1' class=contentlink onclick=query('KNH','C','','');>KNH</a></td><td class=\"content\" align=\"center\" bgcolor=\"#D1EEDC\">12/08/21 13:15</td><td class=\"content\" align=\"center\" bgcolor=\"#D1EEDC\">12/08/21 14:10</td><td class=\"content\" align=\"center\" bgcolor=\"#D1EEDC\">12/08/21 13:15</td><td class=\"content\" align=\"center\" bgcolor=\"#D1EEDC\">12/08/21 14:21</td><td class=\"content\" align=\"center\" bgcolor=\"#D1EEDC\"><font color=\"Red\">12/08/21 13:23</font></td><td class=\"content\" align=\"center\" bgcolor=\"#D1EEDC\"><font color=\"Red\">12/08/21 14:18</font></td><td class=\"txtg\" align=\"center\" bgcolor=\"#D1EEDC\">抵達</td><td class=\"content\" align=\"center\" bgcolor=\"#D1EEDC\">-</td>";
//		System.out.println(temp.contains("B70887"));
//        System.out.println(temp.contains("B70889"));
//        
//		temp = "</tr><tr class=\"row0\">";
//		System.out.println(temp.contains("B70887"));
//        System.out.println(temp.contains("B70889"));
        
//        for (int j=0; j<10; j++) {
//            
//            System.out.println(j);
//            
//            if (j == 5) {
//                
//                System.out.println("exit");
//                break;
//                
//            }
//            
//        }
        
        
    }
    
    
	
	/**
	 * 金門
	 */
	public ArrayList<FlightBean> updateKNH(ArrayList<FlightBean> beans) throws Exception{
//    public ArrayList<FlightBean> getKNH() throws Exception{

        
        FlightBean bean = null;
        String temp = "";
        

        try {

          //time
            Date date = new Date();
            DateFormat secondFormat = new SimpleDateFormat("yyyy M d HH mm ss");
            TimeZone secondTime = TimeZone.getTimeZone("Asia/Taipei");
            secondFormat.setTimeZone(secondTime);
            
            String t = secondFormat.format(date);
            
            String [] ts = t.split(" ");
            
            String year = ts[0];
            String month = ts[1];
            String day = ts[2];
          
            /**
             * read from URL
             */
            URL tsa = new URL("http://eservice.evaair.com/EVAB2C/ESEVfls001.aspx?language=en&Company=UNIAIR&type=A&orderby3=1&reqtime=5&reqdate2=" + year + "/" + month + "/" + day + "&options=2&fromcity=TSA&tocity=KNH");
            
            
            URLConnection urlc = tsa.openConnection();
            urlc.setRequestProperty("Content-Type", "text/xml;charset=UTF-8");
            urlc.setDoOutput(true);
            urlc.setDoInput(true);
            
            
            BufferedReader in = new BufferedReader(new InputStreamReader(urlc.getInputStream()));

            //set today variable
            year = year.substring(2);
            if (month.length()==1) month = "0" + month;
            if (day.length()==1) day = "0" + day;
            String today = year + "/" + month + "/" + day;
            
                        
            //getting flight info
            ArrayList<String> flightNo = new ArrayList<String>();
            ArrayList<String> flightTime = new ArrayList<String>();
            
            String str;
            while ((str = in.readLine()) != null) {
                if (str.contains(today) && 
                    str.contains("<td class=\"content\" align=\"center\"") ) {
                    
                    str = str.trim();

                    bean = new FlightBean();

                    //flight no
                    temp = str.substring(str.indexOf("B7")+2, str.indexOf("</"));
                    if (temp.charAt(0)=='0') temp = temp.substring(1, 4);
//                    System.out.println(temp);
                    flightNo.add(temp);
                    
                    /**
                     * estimated departure time
                     */
                    temp = str.substring(str.indexOf(today)+1); //1
                    temp = temp.substring(temp.indexOf(today)+1); //2
                    
                    //getting actual departure time if available
                    String actual = temp.substring(temp.indexOf(today)+1); //3
                    actual = actual.substring(actual.indexOf(today)+1); //4
                    
                    //has actual departure time
                    if (actual.contains(today)) {
                        
                        actual = actual.substring(actual.indexOf(today)+9, actual.indexOf(today)+14);
                        actual = actual.substring(0, 2) + actual.substring(3, 5);
                        flightTime.add(actual);
                        
                    //don't have actual departure time, but estimated
                    } else {                    
                        
                        String estimated = temp.substring(temp.indexOf(today)+9, temp.indexOf(today)+14);
                        estimated = estimated.substring(0, 2) + estimated.substring(3, 5);
    //                    System.out.println(temp);
                        flightTime.add(estimated);
                        
                    }
                    
                    
                }
            }
            
            in.close();
  
            
            //update beans with retrieved flight info
            for (int i=0; i<beans.size(); i++) {
                
                if (beans.get(i).getAirline().equals("B7")) {
                
                    for (int j=0; j<flightNo.size(); j++) {
                        
                        if (beans.get(i).getFlightNo().equals(flightNo.get(j))) {
                            
                            bean = beans.get(i);
                            bean.setActualTime(flightTime.get(j));
                            beans.set(i, bean);
                            break;
                            
                        }
                        
                    }
                    
                }
                
            }

            
                
            } catch (IOException e) {
                e.getStackTrace();
            }
      
        return beans;
            
    }
	  
    
    /**
     * 台東
     */
    public ArrayList<FlightBean> updateTTT(ArrayList<FlightBean> beans) throws Exception{
        
        
        FlightBean bean = null;
        String temp = "";
        

        try {

          //time
            Date date = new Date();
            DateFormat secondFormat = new SimpleDateFormat("yyyy M d HH mm ss");
            TimeZone secondTime = TimeZone.getTimeZone("Asia/Taipei");
            secondFormat.setTimeZone(secondTime);
            
            String t = secondFormat.format(date);
            
            String [] ts = t.split(" ");
            
            String year = ts[0];
            String month = ts[1];
            String day = ts[2];
          
            /**
             * read from URL
             */
            URL tsa = new URL("http://eservice.evaair.com/EVAB2C/ESEVfls001.aspx?language=en&Company=UNIAIR&type=A&orderby3=1&reqtime=5&reqdate2=" + year + "/" + month + "/" + day + "&options=2&fromcity=TSA&tocity=TTT");
            
            
            URLConnection urlc = tsa.openConnection();
            urlc.setRequestProperty("Content-Type", "text/xml;charset=UTF-8");
            urlc.setDoOutput(true);
            urlc.setDoInput(true);
            
            
            BufferedReader in = new BufferedReader(new InputStreamReader(urlc.getInputStream()));

            //set today variable
            year = year.substring(2);
            if (month.length()==1) month = "0" + month;
            if (day.length()==1) day = "0" + day;
            String today = year + "/" + month + "/" + day;
            
                        
            //getting flight info
            ArrayList<String> flightNo = new ArrayList<String>();
            ArrayList<String> flightTime = new ArrayList<String>();
            
            String str;
            while ((str = in.readLine()) != null) {
                if (str.contains(today) && 
                    str.contains("<td class=\"content\" align=\"center\"") ) {
                    
                    str = str.trim();

                    bean = new FlightBean();

                    //flight no
                    temp = str.substring(str.indexOf("B7")+2, str.indexOf("</"));
                    if (temp.charAt(0)=='0') temp = temp.substring(1, 4);
//                    System.out.println(temp);
                    flightNo.add(temp);

                    /**
                     * estimated departure time
                     */
                    temp = str.substring(str.indexOf(today)+1); //1
                    temp = temp.substring(temp.indexOf(today)+1); //2
                    
                    //getting actual departure time if available
                    String actual = temp.substring(temp.indexOf(today)+1); //3
                    actual = actual.substring(actual.indexOf(today)+1); //4
                    
                    //has actual departure time
                    if (actual.contains(today)) {
                        
                        actual = actual.substring(actual.indexOf(today)+9, actual.indexOf(today)+14);
                        actual = actual.substring(0, 2) + actual.substring(3, 5);
                        flightTime.add(actual);
                        
                    //don't have actual departure time, but estimated
                    } else {                    
                        
                        String estimated = temp.substring(temp.indexOf(today)+9, temp.indexOf(today)+14);
                        estimated = estimated.substring(0, 2) + estimated.substring(3, 5);
    //                    System.out.println(temp);
                        flightTime.add(estimated);
                        
                    }
                    
                    
                }
            }
            
            in.close();
  

            
            //update beans with retrieved flight info
            for (int i=0; i<beans.size(); i++) {
                
                if (beans.get(i).getAirline().equals("B7")) {
                
                    for (int j=0; j<flightNo.size(); j++) {
                        
                        if (beans.get(i).getFlightNo().equals(flightNo.get(j))) {
                            
                            bean = beans.get(i);
                            bean.setActualTime(flightTime.get(j));
                            beans.set(i, bean);
                            break;
                            
                        }
                        
                    }
                    
                }
                
            }
            
            
                
            } catch (IOException e) {
                e.getStackTrace();
            }
      
        return beans;
        
    }
    
    
    /**
     * 澎湖馬公
     */
    public ArrayList<FlightBean> updateMZG(ArrayList<FlightBean> beans) throws Exception{
        
        
        FlightBean bean = null;
        String temp = "";
        

        try {

          //time
            Date date = new Date();
            DateFormat secondFormat = new SimpleDateFormat("yyyy M d HH mm ss");
            TimeZone secondTime = TimeZone.getTimeZone("Asia/Taipei");
            secondFormat.setTimeZone(secondTime);
            
            String t = secondFormat.format(date);
            
            String [] ts = t.split(" ");
            
            String year = ts[0];
            String month = ts[1];
            String day = ts[2];
          
            /**
             * read from URL
             */
            URL tsa = new URL("http://eservice.evaair.com/EVAB2C/ESEVfls001.aspx?language=en&Company=UNIAIR&type=A&orderby3=1&reqtime=5&reqdate2=" + year + "/" + month + "/" + day + "&options=2&fromcity=TSA&tocity=MZG");
            
            
            URLConnection urlc = tsa.openConnection();
            urlc.setRequestProperty("Content-Type", "text/xml;charset=UTF-8");
            urlc.setDoOutput(true);
            urlc.setDoInput(true);
            
            
            BufferedReader in = new BufferedReader(new InputStreamReader(urlc.getInputStream()));

            //set today variable
            year = year.substring(2);
            if (month.length()==1) month = "0" + month;
            if (day.length()==1) day = "0" + day;
            String today = year + "/" + month + "/" + day;
            
                        
            //getting flight info
            ArrayList<String> flightNo = new ArrayList<String>();
            ArrayList<String> flightTime = new ArrayList<String>();
            
            String str;
            while ((str = in.readLine()) != null) {
                if (str.contains(today) && 
                    str.contains("<td class=\"content\" align=\"center\"") ) {
                    
                    str = str.trim();

                    bean = new FlightBean();

                    //flight no
                    temp = str.substring(str.indexOf("B7")+2, str.indexOf("</"));
                    if (temp.charAt(0)=='0') temp = temp.substring(1, 4);
//                    System.out.println(temp);
                    flightNo.add(temp);

                    /**
                     * estimated departure time
                     */
                    temp = str.substring(str.indexOf(today)+1); //1
                    temp = temp.substring(temp.indexOf(today)+1); //2
                    
                    //getting actual departure time if available
                    String actual = temp.substring(temp.indexOf(today)+1); //3
                    actual = actual.substring(actual.indexOf(today)+1); //4
                    
                    //has actual departure time
                    if (actual.contains(today)) {
                        
                        actual = actual.substring(actual.indexOf(today)+9, actual.indexOf(today)+14);
                        actual = actual.substring(0, 2) + actual.substring(3, 5);
                        flightTime.add(actual);
                        
                    //don't have actual departure time, but estimated
                    } else {                    
                        
                        String estimated = temp.substring(temp.indexOf(today)+9, temp.indexOf(today)+14);
                        estimated = estimated.substring(0, 2) + estimated.substring(3, 5);
    //                    System.out.println(temp);
                        flightTime.add(estimated);
                        
                    }
                    
                    
                }
            }
            
            in.close();
  

            //update beans with retrieved flight info
            for (int i=0; i<beans.size(); i++) {
                
                if (beans.get(i).getAirline().equals("B7")) {
                
                    for (int j=0; j<flightNo.size(); j++) {
                        
                        if (beans.get(i).getFlightNo().equals(flightNo.get(j))) {
                            
                            bean = beans.get(i);
                            bean.setActualTime(flightTime.get(j));
                            beans.set(i, bean);
                            break;
                            
                        }
                        
                    }
                    
                }
                
            }
            
                
            } catch (IOException e) {
                e.getStackTrace();
            }
      
        return beans;
        
    }
    
    /**
     * 馬祖南竿
     */
    public ArrayList<FlightBean> updateLZN(ArrayList<FlightBean> beans) throws Exception{
        
        
        FlightBean bean = null;
        String temp = "";
        

        try {

          //time
            Date date = new Date();
            DateFormat secondFormat = new SimpleDateFormat("yyyy M d HH mm ss");
            TimeZone secondTime = TimeZone.getTimeZone("Asia/Taipei");
            secondFormat.setTimeZone(secondTime);
            
            String t = secondFormat.format(date);
            
            String [] ts = t.split(" ");
            
            String year = ts[0];
            String month = ts[1];
            String day = ts[2];
          
            /**
             * read from URL
             */
            URL tsa = new URL("http://eservice.evaair.com/EVAB2C/ESEVfls001.aspx?language=en&Company=UNIAIR&type=A&orderby3=1&reqtime=5&reqdate2=" + year + "/" + month + "/" + day + "&options=2&fromcity=TSA&tocity=LZN");
            
            
            URLConnection urlc = tsa.openConnection();
            urlc.setRequestProperty("Content-Type", "text/xml;charset=UTF-8");
            urlc.setDoOutput(true);
            urlc.setDoInput(true);
            
            
            BufferedReader in = new BufferedReader(new InputStreamReader(urlc.getInputStream()));

            //set today variable
            year = year.substring(2);
            if (month.length()==1) month = "0" + month;
            if (day.length()==1) day = "0" + day;
            String today = year + "/" + month + "/" + day;
            
                        
            //getting flight info
            ArrayList<String> flightNo = new ArrayList<String>();
            ArrayList<String> flightTime = new ArrayList<String>();
            
            String str;
            while ((str = in.readLine()) != null) {
                if (str.contains(today) && 
                    str.contains("<td class=\"content\" align=\"center\"") ) {
                    
                    str = str.trim();

                    bean = new FlightBean();

                    //flight no
                    temp = str.substring(str.indexOf("B7")+2, str.indexOf("</"));
                    if (temp.charAt(0)=='0') temp = temp.substring(1, 4);
//                    System.out.println(temp);
                    flightNo.add(temp);

                    /**
                     * estimated departure time
                     */
                    temp = str.substring(str.indexOf(today)+1); //1
                    temp = temp.substring(temp.indexOf(today)+1); //2
                    
                    //getting actual departure time if available
                    String actual = temp.substring(temp.indexOf(today)+1); //3
                    actual = actual.substring(actual.indexOf(today)+1); //4
                    
                    //has actual departure time
                    if (actual.contains(today)) {
                        
                        actual = actual.substring(actual.indexOf(today)+9, actual.indexOf(today)+14);
                        actual = actual.substring(0, 2) + actual.substring(3, 5);
                        flightTime.add(actual);
                        
                    //don't have actual departure time, but estimated
                    } else {                    
                        
                        String estimated = temp.substring(temp.indexOf(today)+9, temp.indexOf(today)+14);
                        estimated = estimated.substring(0, 2) + estimated.substring(3, 5);
    //                    System.out.println(temp);
                        flightTime.add(estimated);
                        
                    }
                    
                    
                }
            }
            
            in.close();
  

            //update beans with retrieved flight info
            for (int i=0; i<beans.size(); i++) {
                
                if (beans.get(i).getAirline().equals("B7")) {
                
                    for (int j=0; j<flightNo.size(); j++) {
                        
                        if (beans.get(i).getFlightNo().equals(flightNo.get(j))) {
                            
                            bean = beans.get(i);
                            bean.setActualTime(flightTime.get(j));
                            beans.set(i, bean);
                            break;
                            
                        }
                        
                    }
                    
                }
                
            }
            
            
                
            } catch (IOException e) {
                e.getStackTrace();
            }
      
        return beans;
        
    }
    
    /**
     * 馬祖北竿
     */
    public ArrayList<FlightBean> updateMFK(ArrayList<FlightBean> beans) throws Exception{
        
        
        FlightBean bean = null;
        String temp = "";
        

        try {

          //time
            Date date = new Date();
            DateFormat secondFormat = new SimpleDateFormat("yyyy M d HH mm ss");
            TimeZone secondTime = TimeZone.getTimeZone("Asia/Taipei");
            secondFormat.setTimeZone(secondTime);
            
            String t = secondFormat.format(date);
            
            String [] ts = t.split(" ");
            
            String year = ts[0];
            String month = ts[1];
            String day = ts[2];
          
            /**
             * read from URL
             */
            URL tsa = new URL("http://eservice.evaair.com/EVAB2C/ESEVfls001.aspx?language=en&Company=UNIAIR&type=A&orderby3=1&reqtime=5&reqdate2=" + year + "/" + month + "/" + day + "&options=2&fromcity=TSA&tocity=MFK");
//            URL tsa = new URL("http://www.taoyuan-airport.com");
            
            
            URLConnection urlc = tsa.openConnection();
            urlc.setRequestProperty("Content-Type", "text/xml;charset=UTF-8");
            urlc.setDoOutput(true);
            urlc.setDoInput(true);
            
            
            BufferedReader in = new BufferedReader(new InputStreamReader(urlc.getInputStream()));

            //set today variable
            year = year.substring(2);
            if (month.length()==1) month = "0" + month;
            if (day.length()==1) day = "0" + day;
            String today = year + "/" + month + "/" + day;
            
                        
            //getting flight info
            ArrayList<String> flightNo = new ArrayList<String>();
            ArrayList<String> flightTime = new ArrayList<String>();
            
            String str;
            while ((str = in.readLine()) != null) {
                if (str.contains(today) && 
                    str.contains("<td class=\"content\" align=\"center\"") ) {
                    
                    str = str.trim();

                    bean = new FlightBean();

                    //flight no
                    temp = str.substring(str.indexOf("B7")+2, str.indexOf("</"));
                    if (temp.charAt(0)=='0') temp = temp.substring(1, 4);
//                    System.out.println(temp);
                    flightNo.add(temp);

                    /**
                     * estimated departure time
                     */
                    temp = str.substring(str.indexOf(today)+1); //1
                    temp = temp.substring(temp.indexOf(today)+1); //2
                    
                    //getting actual departure time if available
                    String actual = temp.substring(temp.indexOf(today)+1); //3
                    actual = actual.substring(actual.indexOf(today)+1); //4
                    
                    //has actual departure time
                    if (actual.contains(today)) {
                        
                        actual = actual.substring(actual.indexOf(today)+9, actual.indexOf(today)+14);
                        actual = actual.substring(0, 2) + actual.substring(3, 5);
                        flightTime.add(actual);
                        
                    //don't have actual departure time, but estimated
                    } else {                    
                        
                        String estimated = temp.substring(temp.indexOf(today)+9, temp.indexOf(today)+14);
                        estimated = estimated.substring(0, 2) + estimated.substring(3, 5);
    //                    System.out.println(temp);
                        flightTime.add(estimated);
                        
                    }
                    
                    
                }
            }
            
            in.close();
  

            //update beans with retrieved flight info
            for (int i=0; i<beans.size(); i++) {
                
                if (beans.get(i).getAirline().equals("B7")) {
                
                    for (int j=0; j<flightNo.size(); j++) {
                        
                        if (beans.get(i).getFlightNo().equals(flightNo.get(j))) {
                            
                            bean = beans.get(i);
                            bean.setActualTime(flightTime.get(j));
                            beans.set(i, bean);
                            break;
                            
                        }
                        
                    }
                    
                }
                
            }
            
                
            } catch (IOException e) {
                e.getStackTrace();
            }
      
        return beans;
        
    }
    
    /**
     * 屏東恆春
     */
    public ArrayList<FlightBean> updateHCN(ArrayList<FlightBean> beans) throws Exception{
        
        
        FlightBean bean = null;
        String temp = "";
        

        try {

          //time
            Date date = new Date();
            DateFormat secondFormat = new SimpleDateFormat("yyyy M d HH mm ss");
            TimeZone secondTime = TimeZone.getTimeZone("Asia/Taipei");
            secondFormat.setTimeZone(secondTime);
            
            String t = secondFormat.format(date);
            
            String [] ts = t.split(" ");
            
            String year = ts[0];
            String month = ts[1];
            String day = ts[2];
          
            /**
             * read from URL
             */
            URL tsa = new URL("http://eservice.evaair.com/EVAB2C/ESEVfls001.aspx?language=en&Company=UNIAIR&type=A&orderby3=1&reqtime=5&reqdate2=" + year + "/" + month + "/" + day + "&options=2&fromcity=TSA&tocity=HCN");
            
            
            URLConnection urlc = tsa.openConnection();
            urlc.setRequestProperty("Content-Type", "text/xml;charset=UTF-8");
            urlc.setDoOutput(true);
            urlc.setDoInput(true);
            
            
            BufferedReader in = new BufferedReader(new InputStreamReader(urlc.getInputStream()));

            //set today variable
            year = year.substring(2);
            if (month.length()==1) month = "0" + month;
            if (day.length()==1) day = "0" + day;
            String today = year + "/" + month + "/" + day;
            
                        
            //getting flight info
            ArrayList<String> flightNo = new ArrayList<String>();
            ArrayList<String> flightTime = new ArrayList<String>();
            
            String str;
            while ((str = in.readLine()) != null) {
                if (str.contains(today) && 
                    str.contains("<td class=\"content\" align=\"center\"") ) {
                    
                    str = str.trim();

                    bean = new FlightBean();

                    //flight no
                    temp = str.substring(str.indexOf("B7")+2, str.indexOf("</"));
                    if (temp.charAt(0)=='0') temp = temp.substring(1, 4);
//                    System.out.println(temp);
                    flightNo.add(temp);

                    /**
                     * estimated departure time
                     */
                    temp = str.substring(str.indexOf(today)+1); //1
                    temp = temp.substring(temp.indexOf(today)+1); //2
                    
                    //getting actual departure time if available
                    String actual = temp.substring(temp.indexOf(today)+1); //3
                    actual = actual.substring(actual.indexOf(today)+1); //4
                    
                    //has actual departure time
                    if (actual.contains(today)) {
                        
                        actual = actual.substring(actual.indexOf(today)+9, actual.indexOf(today)+14);
                        actual = actual.substring(0, 2) + actual.substring(3, 5);
                        flightTime.add(actual);
                        
                    //don't have actual departure time, but estimated
                    } else {                    
                        
                        String estimated = temp.substring(temp.indexOf(today)+9, temp.indexOf(today)+14);
                        estimated = estimated.substring(0, 2) + estimated.substring(3, 5);
    //                    System.out.println(temp);
                        flightTime.add(estimated);
                        
                    }
                    
                    
                }
            }
            
            in.close();
  

            //update beans with retrieved flight info
            for (int i=0; i<beans.size(); i++) {
                
                if (beans.get(i).getAirline().equals("B7")) {
                
                    for (int j=0; j<flightNo.size(); j++) {
                        
                        if (beans.get(i).getFlightNo().equals(flightNo.get(j))) {
                            
                            bean = beans.get(i);
                            bean.setActualTime(flightTime.get(j));
                            beans.set(i, bean);
                            break;
                            
                        }
                        
                    }
                    
                }
                
            }
            
            
                
            } catch (IOException e) {
                e.getStackTrace();
            }
      
        return beans;
        
    }
    
}
